package com.mzy.basics.runtimeException;

/**
 * @author Ives
 * * @date 2022/1/20
 */
/**
 * <p>Title: BusinessException</p>
 * <p>Description:業務異常</p>
 * @author lins
 * @date 2019年05月07日 16:27:21
 */
public class BusinessException extends RuntimeException {

  private static final long serialVersionUID = 7601426179537049976L;

  public static final String BUSINESS_ERROR_CODE = "00000001";

  public static final String BUSINESS_ERROR_MESSAGE = "業務错误";

  private final String code;

  private final String message;

  private final transient Object[] args;

  public BusinessException(String message, Object ...args) {
    this(BUSINESS_ERROR_CODE, message, null, args);
  }

  public BusinessException(String code, String message, Object ...args) {
    this(code, message, null, args);
  }

  public BusinessException(String code, String message, Throwable throwable, Object ...args) {
    super(throwable);
    this.code = code;
    this.message = String.format(message, args);
    this.args = args;
  }

  public String getCode() {
    return code;
  }

  @Override
  public String getMessage() {
    return message;
  }

  public Object[] getArgs() {
    return args;
  }

}
